home *** CD-ROM | disk | FTP | other *** search
- Path: erich.triumf.ca!bennett
- From: bennett@erich.triumf.ca (P.Bennett)
- Newsgroups: comp.lang.c
- Subject: Re: sscanf bug??????
- Date: 10 Feb 1996 22:21 PST
- Organization: TRIUMF: Tri-University Meson Facility
- Distribution: world
- Message-ID: <10FEB199622213548@erich.triumf.ca>
- References: <4fimvo$82s@fnord.dfw.net>
- NNTP-Posting-Host: ftp.triumf.ca
- News-Software: VAX/VMS VNEWS 1.50
-
- In article <4fimvo$82s@fnord.dfw.net>, jtmcap@dfw.dfw.net (Jerry Jackson) writes...
- >the following is a program compiled using microway ndp c/c++ compiler.
- >
- >#include <stdio.h>
- >#include <string.h>
- >
- >main()
- >{
- > char str_1[] = "013196";
- > char str_2[] = "13196";
- > long res_1, res_2;
- >
- > sscanf(str_1,"%d",&res_1);
- > sscanf(str_2,"%d",&res_2);
- >
- > printf("\nres_1 = %d",res_1);
- > printf("\nres_2 = %d",res_2);
-
- Borland says that you need to use "%ld" for long ints in both printf() and
- scanf(). If ints and longs are the same size (as on many unix systems, I
- believe) "%d" and "%ld" can be used interchangeably, but if they are not the
- same (as on MS-DOS) then it _does_ make a difference.
-
- >microway says that the leading zero causes sscanf to do an octal
- >conversion on the integer.
-
- Borland indicates you need "%o" to read octal numbers. Reading quiclky through
- the description of scanf(), I don't see any indication that a leading 0 will
- trigger an octal conversion...
-
- Peter Bennett VE7CEI | Vessels shall be deemed to be in sight
- Internet: bennett@triumf.ca | of one another only when one can be
- Packet: ve7cei@ve7kit.#vanc.bc.ca | observed visually from the other
- TRIUMF, Vancouver, B.C., Canada | ColRegs 3(k)
- GPS and NMEA info and programs: ftp://sundae.triumf.ca/pub/peter/index.html
-
-
-
-
-
-
-
-
-